package abq2.jic.jic.plugin.operate.teacherEvaluate;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.MobileFormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.operate.FormOperate;
import kd.bos.list.BillList;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.DeleteServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin;

/**
 * 单据界面插件
 */
public class TeacherEvaluate extends AbstractBillPlugIn implements Plugin {

    String act_id = "evaluateconf";
    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs e) {

        super.beforeDoOperation(e);
        String operateKey = ((FormOperate) e.getSource()).getOperateKey();
        if(((FormOperate)e.getSource()).getOperateKey().equals("evaluatebegin")){
            BillList billlist = this.getControl("abq2_billlistap");
            ListSelectedRow currentSelectedRowInfo = billlist.getCurrentSelectedRowInfo();

            Object primaryKeyValue = currentSelectedRowInfo.getPrimaryKeyValue();

            //弹窗界面
            FormShowParameter formShowParameter = new MobileFormShowParameter();
            formShowParameter.setFormId("abq2_evaluate_window");
            formShowParameter.setCustomParam("teacherId",primaryKeyValue);
            formShowParameter.setCloseCallBack(new CloseCallBack(this,act_id));
            formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
            this.getView().showForm(formShowParameter);
        }else if (operateKey.equals("refresh")){
            BillList billList = this.getControl("abq2_billlistap");
            billList.refresh();
            billList.refreshData();
        }else if (operateKey.equals("close")){
            this.getView().close();
        }
    }

    @Override
    public void closedCallBack(ClosedCallBackEvent a) {
        super.closedCallBack(a);
        String actionId = a.getActionId();
        if (actionId.equalsIgnoreCase(act_id)){
            Object returnData = a.getReturnData();
            if (returnData != null){
                Boolean b = (Boolean) returnData;
                if (b){
                    this.getView().showSuccessNotification("评教成功");
                }
            }
        }
        BillList billList = this.getControl("abq2_billlistap");
        billList.refresh();
        billList.refreshData();
    }

    @Override
    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
        super.afterDoOperation(afterDoOperationEventArgs);
    }
}